package com.adtech.farmProducts.adapter;

import android.view.View;
import android.widget.TextView;

import com.adtech.common.widgets.recycler.RecyclerViewAdapter;
import com.adtech.farmProducts.R;
import com.adtech.farmProducts.model.CommodityTypeItem;


/**
 * Author:  xiaocz.
 * Descr:  产品分类-详情
 */
public class CommodityTypeItemAdapter extends RecyclerViewAdapter<CommodityTypeItem> {

    public CommodityTypeItemAdapter(AdapterListener<CommodityTypeItem> adapterListener) {
        super(adapterListener);
    }

    @Override
    protected int getItemViewType(int position, CommodityTypeItem data) {
        return R.layout.item_commodity_type;
    }

    @Override
    protected ViewHolder<CommodityTypeItem> getViewHolder(View view, int viewType) {
        return new InfoTypeViewHolder(view);
    }

    private static class InfoTypeViewHolder extends ViewHolder<CommodityTypeItem> {

        private TextView tvName;

        private InfoTypeViewHolder(View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_name);
        }

        @Override
        protected void onBind(CommodityTypeItem data, int position) {
            tvName.setText(data.getProductTypeName());
        }

        @Override
        public boolean isNeedClick() {
            return true;
        }
    }
}